import com.hanxu.dao.UserMapper;
import com.hanxu.pojo.User;
import com.hanxu.utlis.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class Mytest {


    /**
     * 获取全部的用户
     */
    @Test
    public void anno(){

        SqlSession sqlsession = MybatisUtils.getSqlsession();

        UserMapper mapper = sqlsession.getMapper(UserMapper.class);

        List<User> allUser = mapper.getAllUser();

        for (User user : allUser) {
            System.out.println(user);
        }

        sqlsession.close();

    }

    /**
     * 根据id 获取用户
     */
    @Test
    public void annobyid(){

        SqlSession sqlsession = MybatisUtils.getSqlsession();

        UserMapper mapper = sqlsession.getMapper(UserMapper.class);

        User user = mapper.gerUserById(2);
        System.out.println(user);

        sqlsession.close();
    }

}
